#ifndef _PROCESSOR_H_
#define _PROCESSOR_H_

#include "resource.h"
#include "filechecker.h"

class Processor : public Resource {
	private:
		/*The trace of the cpu*/
		const char *cpu_avail_trace;
		
		/* The trace of the cpu error */
		const char *cpu_avail_error;
		
		/*the forecast of teh cpu*/
		const char *cpu_avail_forecast;
		
		SG_Trace forecast_cpu;
		SG_Trace error_cpu;
	
	public:
		/*Constructor using trace files for cpu_availability*/
		Processor(const char *name, long double relSpeed, const char *cpu_avail_trace, long double cpu_offset, const char *cpu_avail_error, const char *cpu_avail_forecast=NULL);
		/*Constructor using fixed value for cpu availability*/
		Processor(const char *name, long double relSpeed, long double fixed_cpu);
		/*Destructor*/
		~Processor();
		/*Gets the relative cpu speed*/
		long double getCpuSpeed();
		/*Get the cpu available*/
		long double getCpuAvailable(long double time);
		/* Get the cpu available error */
		long double getCpuAvailableError(long double time);
		/*Get the cpu available trace*/
		const char *getCpuAvailableTrace();
		/* Get the cpu available error trace */
		const char *getCpuAvailableErrorTrace();
		/*Get the cpu available trace*/
		const char *getCpuAvailableForecast();
		/*Get and Set the cpu offset used*/
		long double getCpuOffset();
		void setCpuOffset(long double new_offset);
		/*Return true if the processor is busy*/
		bool isBusy();
		/*Get the current number of tasks allocated to this processor*/
		int getNumberOfAllocatedTasks();
		/*Get the number of running tasks (sg_running)*/
		int getNumberOfRunningTasks();
		/*Get the number of scheduled tasks (sg_ready and sg_scheduled)*/
		int getNumberOfScheduledTasks();
		
		long double current_granularity;
		long double mean_for_current_granularity;
};

#endif //_PROCESSOR_H_
